# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=vhs
pkgver=0.8.0
pkgrel=0
pkgdesc="Tool for automatic recording of terminal sessions"
url="https://github.com/charmbracelet/vhs"
arch="all"
license="MIT"
depends="ffmpeg ttyd"
makedepends="go"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/charmbracelet/vhs/archive/v$pkgver/vhs-$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"

build() {
	mkdir builddir

	go build -v \
		-trimpath \
		-ldflags "-X main.Version=$pkgver -extldflags \"$LDFLAGS\"" \
		-o builddir .

	./builddir/vhs man > builddir/vhs.1
	./builddir/vhs completion bash > completion.bash
	./builddir/vhs completion fish > completion.fish
	./builddir/vhs completion zsh > completion.zsh
}

check() {
	go test -v ./...
}

package() {
	install -Dm755 builddir/vhs -t "$pkgdir"/usr/bin/
	install -Dm644 builddir/vhs.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 completion.bash \
		"$pkgdir"/usr/share/bash-completion/completions/vhs
	install -Dm644 completion.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/vhs.fish
	install -Dm644 completion.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_vhs
}

sha512sums="
61459c1043eb1eb2bf47efd393bf88133ff4b47f5aa8e547ae77c3ad921cb2d523b666d582ab310cf5c3f4f6115e8cfb85cff04c07c26b569977ea3a9a0ea682  vhs-0.8.0.tar.gz
"
